#include <gmpxx.h>
#include <vector>
#include <string>
#include <map>
#include "CoCoA/library.H"

using namespace CoCoA;
using namespace std;



//! a wrapper for RingElem
class Polynomial {
		public:
				//! trivial constructor
				Polynomial(size_t);

				//! destructor
				~Polynomial();
					
		private:
				//! the actually data for a polynomial
				void* __data;  // the true data, has to be retrived by type indicator
};

CoCoA::GlobalManager CoCoAinitialization; // initialize a CoCoA::GlobalManager

map<size_t, SparsePolyRing> __cocoa_rings; // all CoCoA polynomial rings



//! Create a CoCoA PolyRing from with ring id myring
SparsePolyRing CreatePolyRing(size_t myring){
		map<size_t, SparsePolyRing>::iterator pos=__cocoa_rings.find(myring);
		if (pos != __cocoa_rings.end()){
			return pos->second;
		}
		else{
			pair< map< size_t, SparsePolyRing >::iterator, bool > ret = 
			__cocoa_rings.insert( make_pair(myring, NewPolyRing(RingQ(),symbols("x"))) );
			return ret.first->second;
			}
}


Polynomial::Polynomial(size_t id){
	      __data = new RingElem(CreatePolyRing(id)); //
		 
}

Polynomial::~Polynomial(){
		  delete (RingElem*)__data; // cause error
}


